import datetime
from django.http import HttpResponse
from django.shortcuts import render, redirect


# Create your views here.

def index(request):
    return HttpResponse("欢迎使用django 4-2")


def test1(request):
    # 创建一个时间并且把时间显示到页面中去
    time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    data = {
        'title':'index主',
        'book':'python book'

    }
    return render(request, 'index.html', {'time':time})
    # return render(request, 'index.html', data)

# 重定向
def test2(request):

    # 重定向
    print("你好")
    return HttpResponse("nihao",redirect('/m/time/'),status=304)

